home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byt86aug.arc / MACAPP.USE < prev    next >
Text File  |  1980-01-01  |  7KB  |  243 lines

  1.                                  { The Smallest MacApp Application }
  2.                { Copyright 1986 by Productivity Products International, Inc.}
  3.  
  4. {  The MAIN Program }
  5. PROGRAM SmallApp;
  6.  
  7.  
  8. USES
  9.     { This set of units are portions of the Macintosh ROM }
  10.       MemTypes, QuickDraw, OSIntf, ToolIntf,
  11.  
  12.     { This set of units are portions of MacApp }
  13.           UObject, UList, UMacApp, UPrinting,
  14.  
  15.     { This unit has the SmallApp-specific classes }
  16.           USmallApp;
  17.  
  18.     VAR aSmallApplication:  TSmallApplication;  { The application object -
  19.  only one of these per application }
  20.  
  21.  
  22. BEGIN
  23.     InitToolbox(8);      { initialize the ToolBox; 8 calls to MoreMasters }
  24.     InitPrinting;        { initialize the print shop }
  25.  
  26.     New(aSmallApplication);
  27.     aSmallApplication.ISmallApplication;
  28.     aSmallApplication.Run;
  29. END.
  30.  
  31. { *** The Unit it uses.  This is typically in two separate files:  one for the
  32. interface and one for the implementation.  ***}
  33.  
  34.                            { The Smallest Possible MacApp Application }
  35.                   { Copyright 1986 by Productivity Products International,
  36. Inc. }
  37.  
  38. UNIT USmallApp;
  39.  
  40. INTERFACE
  41.  
  42. USES
  43.   { This set of units are portions of the Macintosh ROM }
  44.     MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
  45.  
  46.   { This set of units are portions of MacApp }
  47.     UObject, UList, UMacApp, UPrinting;
  48.  
  49. CONST
  50.     myFileType  = 'MAMO';     { The file type ("MacApp MOuse') for documents
  51.  of this application }
  52.         mySignature = 'SMAP';     { The application signature of SMall
  53.  APplication }
  54.         myWindowType = 1001;      { The resource ID of the WIND resource which
  55.                                     defines the windows used to
  56.                                     display the documents of this application.
  57.  }
  58.  
  59. TYPE
  60.  
  61.     TSmallApplication = OBJECT(TApplication)
  62.  
  63.             { ----- INITIALIZE THE APPLICATION ----- }
  64.         PROCEDURE TSmallApplication.ISmallApplication;
  65.  
  66.             { ----- MAKE A DOCUMENT ----- }
  67.         FUNCTION  TSmallApplication.DoMakeDocument(itsCmdNumber: CmdNumber):
  68.  TDocument; OVERRIDE;
  69.  
  70.     END;
  71.  
  72.  
  73.  
  74.     TSmallDocument = OBJECT(TDocument)
  75.  
  76.             { ----- FIELDS ----- }
  77.         fSmallView:  TSmallView;
  78.  
  79.             { ----- INITIALIZE A DOCUMENT ----- }
  80.         PROCEDURE TSmallDocument.ISmallDocument;
  81.  
  82.             { ----- MAKE A VIEW ----- }
  83.         PROCEDURE  TSmallDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
  84.  
  85.             { ----- MAKE A WINDOW ----- }
  86.         PROCEDURE  TSmallDocument.DoMakeWindows; OVERRIDE;
  87.  
  88.     END;
  89.  
  90.  
  91.  
  92.     TSmallView = OBJECT(TView)
  93.  
  94.             { ----- INITIALIZE A VIEW ----- }
  95.         PROCEDURE TSmallView.ISmallView(itsSmallDocument: TSmallDocument);
  96.  
  97.             { ----- RENDER THE IMAGE ----- }
  98.         PROCEDURE TSmallView.Draw(area: Rect); OVERRIDE;
  99.  
  100.     END;
  101.  
  102.  
  103. IMPLEMENTATION
  104.  
  105.                 { Copyright 1985 by Productivity Products International, Inc.}
  106.  
  107. { USmallApp Implementation }
  108.  
  109. {
  110. *****************************************************************************}
  111. {
  112. *****************************************************************************}
  113. {                     METHODS FOR ALL THE SMALLAPP CLASSES
  114. }
  115. {
  116. }
  117. {    Note that methods are grouped by class and that the order of methods in
  118.  any class is the following   }
  119. {    (by convention only, since Object Pascal forces no order): }
  120. {
  121. }
  122. {               (1) the initialization method, if any, }
  123. {     (2) the Inspect method - a private debugging method, if needed }
  124. {               (3) the Free method, if overridden, and}
  125. {   (4) the remaining methods in alphabetical order. }
  126. {
  127. }
  128. { ************************************************************************* }
  129. { ************************************************************************* }
  130.  
  131.  
  132.  
  133. { ************** TSmallApplication Methods ********************* }
  134.  
  135. PROCEDURE TSmallApplication.ISmallApplication;
  136. BEGIN
  137.     SELF.IApplication(myFileType);
  138. END;
  139.  
  140.     { ----- MAKE AND INITIALIZE A DOCUMENT ----- }
  141.  
  142. FUNCTION  TSmallApplication.DoMakeDocument(itsCmdNumber: CmdNumber):
  143.  TDocument; OVERRIDE;
  144. VAR aSmallDocument:TSmallDocument;
  145. BEGIN
  146.     NEW(aSmallDocument);
  147.     aSmallDocument.ISmallDocument;
  148.     DoMakeDocument := aSmallDocument;
  149. END;
  150.  
  151.  
  152. { *************** TSmallDocument Methods ********************** }
  153.  
  154. PROCEDURE TSmallDocument.ISmallDocument;
  155. BEGIN
  156.     SELF.IDocument(myFileType, mySignature, TRUE, FALSE);
  157. END;
  158.  
  159.  
  160.     { ----- MAKE AND INITIALIZE ALL THE NECESSARY VIEWS ----- }
  161.  
  162. PROCEDURE  TSmallDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
  163. VAR smallView:   TSmallView;
  164. BEGIN
  165.     NEW(smallView);
  166.     smallView.ISmallView(SELF);
  167.     SELF.fSmallView := smallView;
  168. END;
  169.  
  170.  
  171.     { ----- MAKE ALL THE NECESSARY WINDOWS ----- }
  172.  
  173. PROCEDURE  TSmallDocument.DoMakeWindows; OVERRIDE;
  174. VAR aWindow:    TWindow;
  175. BEGIN
  176.     aWindow := NewSimpleWindow(myWindowType, FALSE { NOT a DialogWindow},
  177.                                kWantHScrollBar, kWantVScrollBar,
  178.  SELF.fSmallView);
  179. END;
  180.  
  181.  
  182.  
  183. { ************************** TSmallView Methods ************************ }
  184.  
  185. PROCEDURE TSmallView.ISmallView(itsSmallDocument: TSmallDocument);
  186. VAR viewRect:       Rect;
  187.     aStdHandler:    TStdPrintHandler;
  188. BEGIN
  189.     SetRect(viewRect, 0, 0, 500, 500);
  190.     IView(NIL,                         { This view has no parent view,  }
  191.           itsSmallDocument,            {  and shows a smallDocument,    }
  192.           viewRect,                    {  in a 500 x 500 rectangle,     }
  193.           sizeFixed,                   {  that does not change if the   }
  194.                                        {  frame is changed horizontally,}
  195.           sizeFixed,                   {  or vertically,                }
  196.           FALSE,                       {  and can't make selections     }
  197.           hlOff);                      {  and doesn't highlight when the}
  198.                                        {  window is inactive. }
  199.  
  200.  
  201.     New(aStdHandler);
  202.     aStdHandler.IStdPrintHandler(SELF, FALSE);  { The second parameter,
  203.      itsSquareDots, is FALSE since this application does not mix text
  204.      and graphics.   Slightly higher resolution is available with this
  205.      setting. }
  206. END;
  207.  
  208.  
  209.  
  210.  
  211.     { ----- RENDER THE IMAGE ----- }
  212.  
  213. PROCEDURE TSmallView.Draw(area: Rect); OVERRIDE;
  214.  
  215.     FUNCTION  MakeRect(top, left, bottom, right: INTEGER): Rect;
  216.     VAR r: Rect;
  217.     BEGIN
  218.         SetRect(r, left, top, right, bottom);
  219.         MakeRect := r;
  220.     END;
  221.  
  222. BEGIN
  223.     PenNormal;
  224.     PaintOval(MakeRect(74, 72, 139, 127));       { Outline of the mouse head }
  225.     EraseOval(MakeRect(84, 74, 138, 125));       { Outline of the mouse face }
  226.     FrameOval(MakeRect(109, 84, 129, 115));      { Mouse mouth (part 1 of 2) }
  227.     EraseRect(MakeRect(109, 84, 123, 115));      { Mouse mouth (part 2 of 2) }
  228.     FrameOval(MakeRect(98, 87, 107, 96));        { Left eye }
  229.     FrameOval(MakeRect(98, 104, 107, 113));      { Right eye }
  230.     PaintOval(MakeRect(101, 90, 104, 93));       { Left pupil }
  231.     PaintOval(MakeRect(101, 107, 104, 110));     { Right pupil }
  232.     PaintOval(MakeRect(111, 97, 117, 103));      { Nose }
  233.     PaintOval(MakeRect(53, 52, 91, 90));         { Left ear }
  234.     PaintOval(MakeRect(53, 110, 91, 148));       { Right ear }
  235.  
  236.     FrameRect(MakeRect(20, 20, 170, 180));       { A bounding rectangle }
  237.  
  238. END;
  239.  
  240.  
  241.  
  242. END.
  243.